package link;

/**
 * 链表中删除指定数值元素
 * Created by zhaoxin on 2018/7/25.
 */
public class Solution3 {

   public LinkedNode removeElements(LinkedNode head, int val){
       if (head == null){
           return null;
       }

//       LinkedNode resultLink = removeElements(head.next, val);
//       if (head.data == val){
//           return resultLink;
//       }else {
//           head.next = resultLink;
//           return head;
//       }

       head.next = removeElements(head.next, val);

       return head.data == val ? head.next : head;
   }

    public static void main(String[] args) {
       int [] arr = {1, 2, 3, 4, 5, 6};
       LinkedNode link = new LinkedNode(arr);

        System.out.println(new Solution3().removeElements(link, 6));
    }


}
